
UPDATE FLW_ID_DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = '192.168.1.15 (192.168.1.15)', LOCKGRANTED = TIMESTAMP('2019-12-04 12:32:52.285') WHERE ID = 1 AND LOCKED = 0;

ALTER TABLE FLW_IDENTITY_INFO ADD TENANT_ID_ VARCHAR(255) DEFAULT '' NOT NULL;

ALTER TABLE FLW_IDENTITY_INFO ADD UPDATE_TIME_ TIMESTAMP;

CALL SYSPROC.ADMIN_CMD ('REORG TABLE FLW_IDENTITY_INFO');

INSERT INTO FLW_ID_DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('14', 'flowable', 'com/flowable/platform/idm/db/liquibase/flowable-idm-db-changelog.xml', CURRENT TIMESTAMP, 14, '7:2fb0837b0f14bc9833977ee1a7b38c4d', 'addColumn tableName=FLW_IDENTITY_INFO', '', 'EXECUTED', NULL, NULL, '3.5.3', '5459173232');

ALTER TABLE FLW_IDENTITY_INFO DROP CONSTRAINT FK_IDENTITY_INFO_ID_USER;

ALTER TABLE FLW_IDENTITY_INFO DROP CONSTRAINT FK_IDENTITY_INFO_ID_GROUP;

ALTER TABLE FLW_ID_USER_ACCOUNT DROP CONSTRAINT FK_ID_USER_ACCOUNT_USER;

DROP INDEX FLW_IDX_IDM_INFO_GROUP_ID;

ALTER TABLE FLW_IDENTITY_INFO DROP COLUMN GROUP_ID_;

CALL SYSPROC.ADMIN_CMD ('REORG TABLE FLW_IDENTITY_INFO');

INSERT INTO FLW_ID_DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('15', 'flowable', 'com/flowable/platform/idm/db/liquibase/flowable-idm-db-changelog.xml', CURRENT TIMESTAMP, 15, '7:6a800059199657c89641941be54aa754', 'dropForeignKeyConstraint baseTableName=FLW_IDENTITY_INFO, constraintName=FK_IDENTITY_INFO_ID_USER; dropForeignKeyConstraint baseTableName=FLW_IDENTITY_INFO, constraintName=FK_IDENTITY_INFO_ID_GROUP; dropForeignKeyConstraint baseTableName=FLW_ID_US...', '', 'EXECUTED', NULL, NULL, '3.5.3', '5459173232');

ALTER TABLE FLW_IDENTITY_INFO ALTER COLUMN  USER_ID_ SET NOT NULL;

CALL SYSPROC.ADMIN_CMD ('REORG TABLE FLW_IDENTITY_INFO');

CALL SYSPROC.ADMIN_CMD ('REORG TABLE FLW_IDENTITY_INFO');

ALTER TABLE FLW_IDENTITY_INFO ADD CONSTRAINT FLW_UQ_ID_INFO_TENANT_USR_NAME UNIQUE (TENANT_ID_, USER_ID_, NAME_);

UPDATE FLW_IDENTITY_INFO INFO
            SET TENANT_ID_ = (SELECT U.TENANT_ID_ FROM FLW_ID_USER U WHERE U.ID_ = INFO.USER_ID_)
            WHERE INFO.USER_ID_ IS NOT NULL;

INSERT INTO FLW_ID_DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('16', 'flowable', 'com/flowable/platform/idm/db/liquibase/flowable-idm-db-changelog.xml', CURRENT TIMESTAMP, 16, '7:dd8bd3f93e7f18b95c88a093a4c44ea2', 'addNotNullConstraint columnName=USER_ID_, tableName=FLW_IDENTITY_INFO; addUniqueConstraint constraintName=FLW_UQ_ID_INFO_TENANT_USR_NAME, tableName=FLW_IDENTITY_INFO; sql', '', 'EXECUTED', NULL, NULL, '3.5.3', '5459173232');

INSERT INTO FLW_IDENTITY_INFO (
            ID_,
            REV_,
            TYPE_,
            NAME_,
            TEXT_,
            USER_ID_,
            TENANT_ID_
            )
            SELECT 'IDM-' || CHR( INT(RAND()*26) + 97) || CHR( INT(RAND()*26) + 97) || CHR( INT(RAND()*26) + 97) || CHR( INT(RAND()*26) + 97) || CHR( INT(RAND()*26) + 97) || CHR( INT(RAND()*26) + 97) || CHR( INT(RAND()*26) + 97) || CHR( INT(RAND()*26) + 97) || CHR( INT(RAND()*26) + 97) || CHR( INT(RAND()*26) + 97) || CHR( INT(RAND()*26) + 97) || CHR( INT(RAND()*26) + 97) || CHR( INT(RAND()*26) + 97) || CHR( INT(RAND()*26) + 97) || CHR( INT(RAND()*26) + 97) || CHR( INT(RAND()*26) + 97) AS ID_,
            0 AS REV_,
            TYPE_,
            NAME_,
            TEXT_,
            USER_ID_,
            TENANT_ID_
            FROM (
            SELECT U.ID_ AS USER_ID_, U.TENANT_ID_ AS TENANT_ID_, 'string' AS TYPE_, '__flowableState' AS NAME_, U.STATE_ AS TEXT_
            FROM FLW_ID_USER U
            WHERE U.STATE_ IS NOT NULL

            UNION

            SELECT U.ID_ AS USER_ID_, U.TENANT_ID_ AS TENANT_ID_, 'string' AS TYPE_, '__flowableSubState' AS NAME_, U.SUB_STATE_ AS TEXT_
            FROM FLW_ID_USER U
            WHERE U.SUB_STATE_ IS NOT NULL

            UNION

            SELECT U.ID_ AS USER_ID_, U.TENANT_ID_ AS TENANT_ID_, 'string' AS TYPE_, '__flowableType' AS NAME_, U.TYPE_ AS TEXT_
            FROM FLW_ID_USER U
            WHERE U.TYPE_ IS NOT NULL

            UNION

            SELECT U.ID_ AS USER_ID_, U.TENANT_ID_ AS TENANT_ID_, 'string' AS TYPE_, '__flowableSubType' AS NAME_, U.SUB_TYPE_ AS TEXT_
            FROM FLW_ID_USER U
            WHERE U.SUB_TYPE_ IS NOT NULL

            UNION

            SELECT U.ID_ AS USER_ID_, U.TENANT_ID_ AS TENANT_ID_, 'string' AS TYPE_, '__flowableLanguage' AS NAME_, U.LANGUAGE_ AS TEXT_
            FROM FLW_ID_USER U
            WHERE U.LANGUAGE_ IS NOT NULL

            UNION

            SELECT U.ID_ AS USER_ID_, U.TENANT_ID_ AS TENANT_ID_, 'string' AS TYPE_, '__flowableTheme' AS NAME_, U.THEME_ AS TEXT_
            FROM FLW_ID_USER U
            WHERE U.THEME_ IS NOT NULL

            UNION

            SELECT U.ID_ AS USER_ID_, U.TENANT_ID_ AS TENANT_ID_, 'string' AS TYPE_, '__flowablePresence' AS NAME_, U.PRESENCE_ AS TEXT_
            FROM FLW_ID_USER U
            WHERE U.PRESENCE_ IS NOT NULL

            UNION

            SELECT U.ID_ AS USER_ID_, U.TENANT_ID_ AS TENANT_ID_, 'string' AS TYPE_, '__flowableUserDefinitionKey' AS NAME_, DEF.KEY_ AS TEXT_
            FROM FLW_ID_USER U
            LEFT JOIN FLW_ID_USER_DEFINITIONS DEF ON U.USER_DEFINITION_ID_ = DEF.ID_
            WHERE U.USER_DEFINITION_ID_ IS NOT NULL

            ) INFO;

ALTER TABLE FLW_ID_USER DROP COLUMN STATE_;

CALL SYSPROC.ADMIN_CMD ('REORG TABLE FLW_ID_USER');

ALTER TABLE FLW_ID_USER DROP COLUMN SUB_STATE_;

CALL SYSPROC.ADMIN_CMD ('REORG TABLE FLW_ID_USER');

ALTER TABLE FLW_ID_USER DROP COLUMN TYPE_;

CALL SYSPROC.ADMIN_CMD ('REORG TABLE FLW_ID_USER');

ALTER TABLE FLW_ID_USER DROP COLUMN SUB_TYPE_;

CALL SYSPROC.ADMIN_CMD ('REORG TABLE FLW_ID_USER');

ALTER TABLE FLW_ID_USER DROP COLUMN LANGUAGE_;

CALL SYSPROC.ADMIN_CMD ('REORG TABLE FLW_ID_USER');

ALTER TABLE FLW_ID_USER DROP COLUMN THEME_;

CALL SYSPROC.ADMIN_CMD ('REORG TABLE FLW_ID_USER');

ALTER TABLE FLW_ID_USER DROP COLUMN PRESENCE_;

CALL SYSPROC.ADMIN_CMD ('REORG TABLE FLW_ID_USER');

ALTER TABLE FLW_ID_USER DROP COLUMN PRESENCE_TIME_;

CALL SYSPROC.ADMIN_CMD ('REORG TABLE FLW_ID_USER');

DROP INDEX FLW_IDX_USER_USER_DEF;

ALTER TABLE FLW_ID_USER DROP COLUMN USER_DEFINITION_ID_;

CALL SYSPROC.ADMIN_CMD ('REORG TABLE FLW_ID_USER');

DROP INDEX FLW_IDX_USER_SYSTEM;

ALTER TABLE FLW_ID_USER DROP COLUMN SYSTEM_ID_;

CALL SYSPROC.ADMIN_CMD ('REORG TABLE FLW_ID_USER');

ALTER TABLE FLW_ID_USER DROP COLUMN SYSTEM_TYPE_;

CALL SYSPROC.ADMIN_CMD ('REORG TABLE FLW_ID_USER');

INSERT INTO FLW_ID_DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('17', 'flowable', 'com/flowable/platform/idm/db/liquibase/flowable-idm-db-changelog.xml', CURRENT TIMESTAMP, 17, '7:0371c1a38aea19dfff04532bd77171b6', 'sql; dropColumn columnName=STATE_, tableName=FLW_ID_USER; dropColumn columnName=SUB_STATE_, tableName=FLW_ID_USER; dropColumn columnName=TYPE_, tableName=FLW_ID_USER; dropColumn columnName=SUB_TYPE_, tableName=FLW_ID_USER; dropColumn columnName=LA...', '', 'EXECUTED', NULL, NULL, '3.5.3', '5459173232');

UPDATE FLW_ID_DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1;


UPDATE FLW_LIC_DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = '192.168.1.15 (192.168.1.15)', LOCKGRANTED = TIMESTAMP('2019-12-04 12:32:56.988') WHERE ID = 1 AND LOCKED = 0;

UPDATE FLW_LIC_DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1;


UPDATE FLW_PL_DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = '192.168.1.15 (192.168.1.15)', LOCKGRANTED = TIMESTAMP('2019-12-04 12:32:57.487') WHERE ID = 1 AND LOCKED = 0;

UPDATE FLW_PL_DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1;


UPDATE ACT_APP_DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = '192.168.1.15 (192.168.1.15)', LOCKGRANTED = TIMESTAMP('2019-12-04 12:32:57.989') WHERE ID = 1 AND LOCKED = 0;

UPDATE ACT_APP_DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1;


UPDATE FLW_FO_DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = '192.168.1.15 (192.168.1.15)', LOCKGRANTED = TIMESTAMP('2019-12-04 12:32:58.456') WHERE ID = 1 AND LOCKED = 0;

UPDATE FLW_FO_DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1;


UPDATE FLW_CO_DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = '192.168.1.15 (192.168.1.15)', LOCKGRANTED = TIMESTAMP('2019-12-04 12:32:58.963') WHERE ID = 1 AND LOCKED = 0;

UPDATE FLW_CO_DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1;


UPDATE FLW_AD_DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = '192.168.1.15 (192.168.1.15)', LOCKGRANTED = TIMESTAMP('2019-12-04 12:32:59.490') WHERE ID = 1 AND LOCKED = 0;

UPDATE FLW_AD_DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1;


UPDATE FLW_AU_DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = '192.168.1.15 (192.168.1.15)', LOCKGRANTED = TIMESTAMP('2019-12-04 12:32:59.948') WHERE ID = 1 AND LOCKED = 0;

UPDATE FLW_AU_DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1;


UPDATE FLW_DO_DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = '192.168.1.15 (192.168.1.15)', LOCKGRANTED = TIMESTAMP('2019-12-04 12:33:00.416') WHERE ID = 1 AND LOCKED = 0;

CREATE TABLE FLW_DO_DATAOBJECT_INSTANCE (ID_ VARCHAR(255) NOT NULL, REV_ INTEGER NOT NULL, DEFINITION_ID_ VARCHAR(255) NOT NULL, DEFINITION_KEY_ VARCHAR(255) NOT NULL, LOOKUP_ID_ VARCHAR(128), CREATION_TIME_ TIMESTAMP NOT NULL, CREATOR_ID_ VARCHAR(128), UPDATE_TIME_ TIMESTAMP NOT NULL, UPDATER_ID_ VARCHAR(128), SCOPE_ID_ VARCHAR(255), SUB_SCOPE_ID_ VARCHAR(255), SCOPE_TYPE_ VARCHAR(255), SCOPE_DEFINITION_ID_ VARCHAR(255), CONSTRAINT PK_DO_DATAOBJECT_INSTANCES PRIMARY KEY (ID_));

INSERT INTO FLW_DO_DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('4', 'flowable', 'com/flowable/dataobject/db/liquibase/flowable-dataobject-db-changelog.xml', CURRENT TIMESTAMP, 4, '7:bd7da678a30c8f6d484f0a72ec1ee20c', 'createTable tableName=FLW_DO_DATAOBJECT_INSTANCE', '', 'EXECUTED', NULL, NULL, '3.5.3', '5459180554');

UPDATE FLW_DO_DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1;


UPDATE FLW_PO_DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = '192.168.1.15 (192.168.1.15)', LOCKGRANTED = TIMESTAMP('2019-12-04 12:33:01.147') WHERE ID = 1 AND LOCKED = 0;

UPDATE FLW_PO_DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1;


UPDATE FLW_SE_DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = '192.168.1.15 (192.168.1.15)', LOCKGRANTED = TIMESTAMP('2019-12-04 12:33:01.595') WHERE ID = 1 AND LOCKED = 0;

ALTER TABLE FLW_SE_DEFINITION ADD REFERENCE_KEY_ VARCHAR(255);

CALL SYSPROC.ADMIN_CMD ('REORG TABLE FLW_SE_DEFINITION');

INSERT INTO FLW_SE_DATABASECHANGELOG (ID, AUTHOR, FILENAME, DATEEXECUTED, ORDEREXECUTED, MD5SUM, DESCRIPTION, COMMENTS, EXECTYPE, CONTEXTS, LABELS, LIQUIBASE, DEPLOYMENT_ID) VALUES ('2', 'flowable', 'com/flowable/serviceregistry/db/liquibase/flowable-serviceregistry-db-changelog.xml', CURRENT TIMESTAMP, 2, '7:fc3161b600f16922c3a5bc99c61599b8', 'addColumn tableName=FLW_SE_DEFINITION', '', 'EXECUTED', NULL, NULL, '3.5.3', '5459181728');

UPDATE FLW_SE_DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1;


UPDATE FLW_TP_DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = '192.168.1.15 (192.168.1.15)', LOCKGRANTED = TIMESTAMP('2019-12-04 12:33:02.316') WHERE ID = 1 AND LOCKED = 0;

UPDATE FLW_TP_DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1;


UPDATE FLW_ENG_DATABASECHANGELOGLOCK SET LOCKED = 1, LOCKEDBY = '192.168.1.15 (192.168.1.15)', LOCKGRANTED = TIMESTAMP('2019-12-04 12:33:02.763') WHERE ID = 1 AND LOCKED = 0;

UPDATE FLW_ENG_DATABASECHANGELOGLOCK SET LOCKED = 0, LOCKEDBY = NULL, LOCKGRANTED = NULL WHERE ID = 1;

